<template>
	<uni-nav-bar title="核销商品" left-icon="left" @clickLeft="navBack" :fixed="true" statusBar></uni-nav-bar>
	<view class="package_sale" v-if="hexiaoInfo">
		<view class="space-between list" v-for="item in hexiaoInfo.goods_list" :key="item.goods_id">
			<image :src="item.image" mode=""></image>
			<view class="direction-start" style="height:153rpx;justify-content:space-around;width:76%;">
				<view class="title">{{item.name}}</view>
				<view class="space-between" style="width:100%">
					<view v-if="item.type==='gem'" style="font-size: 26rpx;color:#5097FB;">
						蓝宝石
						<text style="font-size: 38rpx;margin-left: 10rpx;">{{item.score}}</text>
					</view>
					<view v-else style="font-size: 26rpx;color:#FE3B2E;">
						钱包价格:<text style="font-size: 24rpx;">￥</text>
						<text style="font-size: 38rpx;margin-left: 10rpx;">{{item.money}}</text>
					</view>
					<view>{{hexiaoInfo.driver_name}}</view>
				</view>
				<view class="space-between" style="width:100%">
					<view></view>
					<view>x{{item.nums}}</view>
				</view>
				<!-- <view style="color:#999;font-size: 26rpx;">库存：{{hexiaoInfo.stock}}</view> -->
			</view>
		</view>
		<view class="space-between top">
			<view>订单编号</view>
			<view>{{hexiaoInfo.order_sn}}</view>
		</view>
		<view class="space-between top">
			<view>车友</view>
			<view>{{hexiaoInfo.driver_name}} {{hexiaoInfo.driver_mobile}}</view>
		</view>
		<view class="space-between top">
			<view>照片</view>
			<image :src="hexiaoInfo.staff_image" mode="" style="width:100rpx;height:100rpx;border-radius: 5px;"
				@click="onPreviewImage">
			</image>
		</view>
		<view class="space-between top">
			<view>备注</view>
			<view style="width:70%;text-align: right;">{{hexiaoInfo.staff_des?hexiaoInfo.staff_des:'--'}}</view>
		</view>
		<view class="space-between top">
			<view>提货时间</view>
			<view>{{hexiaoInfo.updatetime}}</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { navBack } from '@/utils/navigator';
	import { ref } from 'vue';
	import { getHexiaoInfo } from '@/gql/earthPushing/order';
	import { toPublish } from '@mqtt';
	import { onLoad } from '@dcloudio/uni-app';
	import { showLoading } from '@/utils/prompt';
	const orderID = ref()
	const hexiaoInfo = ref()
	const imgList = ref([])
	onLoad((pearm) => {
		orderID.value = pearm.id
		init()
	})
	function init() {
		showLoading()
		const payload = {
			query: getHexiaoInfo,
			variables: {
				order_id: Number(orderID.value),
			},
		};
		toPublish(
			'ql/staff/getHexiaoInfo',
			payload,
			(obj : any) => {
				const { getHexiaoInfo } = obj.data;
				hexiaoInfo.value = getHexiaoInfo
				if (getHexiaoInfo.staff_image) {
					imgList.value.push(getHexiaoInfo.staff_image)
				}
			},
		);
	}
	function onPreviewImage() {
		uni.previewImage({
			current: 0,
			urls: imgList.value
		});
	}
</script>

<style scoped lang="less">
	.list {
		margin-bottom:20rpx;
		image {
			width: 153rpx;
			height: 153rpx;
			border-radius: 5px;
		}
	}

	.title {
		width: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.top {
		margin-top: 20rpx;
	}
</style>